home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / term / term34Source.lha / TerminalPanel.c < prev    next >
C/C++ Source or Header  |  1993-07-16  |  19KB  |  710 lines

  1. /*
  2. **    TerminalPanel.c
  3. **
  4. **    Editing panel for terminal configuration
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12. enum    {    GAD_BELLMODE, GAD_ALERTMODE,GAD_EMULATIONMODE, GAD_EMULATION, GAD_SELECT_EMULATION,GAD_FONTMODE,
  13.         GAD_FONT, GAD_SELECT_FONT,GAD_SEND_CR, GAD_SEND_LF,GAD_RECEIVE_CR, GAD_RECEIVE_LF,
  14.         GAD_NUMCOLUMNS, GAD_NUMLINES, GAD_KEYMAP, GAD_SELECT_KEYMAP,
  15.         GAD_USE, GAD_CANCEL,GAD_DEFAULT };
  16.  
  17. STATIC STRPTR    BellType[6],
  18.         AlertType[5],
  19.         EmulationType[6],
  20.         FontType[4],
  21.         CRType[4],
  22.         LFType[4];
  23.  
  24. STATIC WORD    LocalMaxColumns,
  25.         LocalMaxLines;
  26.  
  27. STATIC STRPTR __saveds
  28. ShowColumn(struct Gadget *SomeGadget,WORD Level)
  29. {
  30.     STATIC UBYTE Buffer[10];
  31.  
  32.     if(Level == LocalMaxColumns + 1)
  33.         strcpy(Buffer,LocaleString(MSG_TERMINALPANEL_MAXIMUM_TXT));
  34.     else
  35.         SPrintf(Buffer,LocaleBase ? "%9lD" : "%9ld",Level);
  36.  
  37.     return(Buffer);
  38. }
  39.  
  40. STATIC STRPTR __saveds
  41. ShowLine(struct Gadget *SomeGadget,WORD Level)
  42. {
  43.     STATIC UBYTE Buffer[10];
  44.  
  45.     if(Level == LocalMaxLines + 1)
  46.         strcpy(Buffer,LocaleString(MSG_TERMINALPANEL_MAXIMUM_TXT));
  47.     else
  48.         SPrintf(Buffer,LocaleBase ? "%9lD" : "%9ld",Level);
  49.  
  50.     return(Buffer);
  51. }
  52.  
  53. STATIC struct Gadget *
  54. CreateAllGadgets(struct Configuration *ConfigPtr,struct Gadget *GadgetArray[],struct Gadget **GadgetList,BYTE *Default)
  55. {
  56.     struct Gadget        *Gadget;
  57.     struct NewGadget     NewGadget;
  58.     UWORD             Counter = 0;
  59.  
  60.     SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
  61.  
  62.     LocalizeString(BellType,MSG_TERMINALPANEL_BELL_IGNORE_TXT,MSG_TERMINALPANEL_BELL_DEFAULT_TXT);
  63.     LocalizeString(AlertType,MSG_TERMINALPANEL_ALERT_NONE_TXT,MSG_TERMINALPANEL_ALERT_SIGNAL_SCREEN_TXT);
  64.     LocalizeString(EmulationType,MSG_TERMINALPANEL_EMULATION_ANSI_VT102_TXT,MSG_TERMINALPANEL_EMULATION_HEX_TXT);
  65.     LocalizeString(FontType,MSG_TERMINALPANEL_FONT_STANDARD_TXT,MSG_TERMINALPANEL_FONT_PC_RAW);
  66.     LocalizeString(CRType,MSG_TERMINALPANEL_DOCR_IGNORE_TXT,MSG_TERMINALPANEL_DOCR_AS_CR_LF_TXT);
  67.     LocalizeString(LFType,MSG_TERMINALPANEL_DOLF_IGNORE_TXT,MSG_TERMINALPANEL_DOLF_AS_LF_CR_TXT);
  68.  
  69.     memset(&NewGadget,0,sizeof(struct NewGadget));
  70.  
  71.     if(Gadget = CreateContext(GadgetList))
  72.     {
  73.         LONG Level;
  74.  
  75.         SZ_AddLeftOffset(SZ_LeftOffsetDelta(MSG_TERMINALPANEL_BELL_GAD,MSG_TERMINALPANEL_TEXT_FONT_GAD));
  76.  
  77.         SZ_ResetMaxWidth();
  78.  
  79.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,BellType);
  80.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,AlertType);
  81.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,EmulationType);
  82.         SZ_UpdateMaxWidth(FOLDER_KIND,NULL,20,NULL);
  83.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,FontType);
  84.         SZ_UpdateMaxWidth(TEXT_KIND,NULL,20,NULL);
  85.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_TERMINALPANEL_SELECT_NEW_TEXT_GAD),0,NULL);
  86.  
  87.         SZ_SetWidth(SZ_ResetMaxWidth());
  88.  
  89.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_BELL_GAD);
  90.         NewGadget . ng_GadgetID        = Counter;
  91.  
  92.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  93.             SZ_Adjust,    TRUE,
  94.             SZ_AutoWidth,    TRUE,
  95.  
  96.             GTCY_Labels,    BellType,
  97.             GTCY_Active,    ConfigPtr -> TerminalConfig -> BellMode,
  98.         TAG_DONE);
  99.  
  100.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_ALERT_GAD);
  101.         NewGadget . ng_GadgetID        = Counter;
  102.  
  103.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  104.             SZ_Adjust,    TRUE,
  105.             SZ_AutoWidth,    TRUE,
  106.  
  107.             GTCY_Labels,    AlertType,
  108.             GTCY_Active,    ConfigPtr -> TerminalConfig -> AlertMode,
  109.         TAG_DONE);
  110.  
  111.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_EMULATION_GAD);
  112.         NewGadget . ng_GadgetID        = Counter;
  113.  
  114.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  115.             SZ_Adjust,    TRUE,
  116.             SZ_AutoWidth,    TRUE,
  117.  
  118.             GTCY_Labels,    EmulationType,
  119.             GTCY_Active,    ConfigPtr -> TerminalConfig -> EmulationMode,
  120.         TAG_DONE);
  121.  
  122.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_EMULATION_NAME_GAD);
  123.         NewGadget . ng_GadgetID        = Counter;
  124.  
  125.         GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
  126.             SZ_Adjust,    TRUE,
  127.             SZ_AutoWidth,    TRUE,
  128.             SZ_LeaveFolder,    TRUE,
  129.  
  130.             GTST_MaxChars,    255,
  131.             GTST_String,    ConfigPtr -> TerminalConfig -> EmulationFileName,
  132.         TAG_DONE);
  133.  
  134.         NewGadget . ng_GadgetID        = Counter;
  135.  
  136.         GadgetArray[Counter++] = Gadget = CreateGadget(FILE_KIND,Gadget,&NewGadget,
  137.             SZ_Adjust,    TRUE,
  138.             SZ_AutoWidth,    TRUE,
  139.             SZ_PlaceLeft,    TRUE,
  140.         TAG_DONE);
  141.  
  142.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_FONT_GAD);
  143.         NewGadget . ng_GadgetID        = Counter;
  144.  
  145.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  146.             SZ_Adjust,    TRUE,
  147.             SZ_AutoWidth,    TRUE,
  148.  
  149.             GTCY_Labels,    FontType,
  150.             GTCY_Active,    ConfigPtr -> TerminalConfig -> FontMode,
  151.             GA_Disabled,    ConfigPtr -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  152.         TAG_DONE);
  153.  
  154.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_TEXT_FONT_GAD);
  155.         NewGadget . ng_GadgetID        = Counter;
  156.  
  157.         SPrintf(SharedBuffer,"%s %ld",ConfigPtr -> TerminalConfig -> TextFontName,ConfigPtr -> TerminalConfig -> TextFontHeight);
  158.  
  159.         GadgetArray[Counter++] = Gadget = CreateGadget(TEXT_KIND,Gadget,&NewGadget,
  160.             SZ_Adjust,    TRUE,
  161.             SZ_AutoWidth,    TRUE,
  162.  
  163.             GTTX_Text,    SharedBuffer,
  164.             GTTX_Border,    TRUE,
  165.             GTTX_CopyText,    TRUE,
  166.         TAG_DONE);
  167.  
  168.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_SELECT_NEW_TEXT_GAD);
  169.         NewGadget . ng_GadgetID        = Counter;
  170.         NewGadget . ng_Flags        = 0;
  171.  
  172.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  173.             SZ_Adjust,    TRUE,
  174.             SZ_AutoWidth,    TRUE,
  175.         TAG_DONE);
  176.  
  177.         SZ_AddLeftOffset(SZ_LeftOffsetDelta(MSG_TERMINALPANEL_SEND_CR_GAD,MSG_TERMINALPANEL_KEYMAP_FILE_GAD));
  178.  
  179.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,CRType);
  180.         SZ_UpdateMaxWidth(CYCLE_KIND,NULL,0,LFType);
  181.         SZ_UpdateMaxWidth(FOLDER_KIND,NULL,20,NULL);
  182.  
  183.         SZ_SetWidth(SZ_ResetMaxWidth());
  184.  
  185.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_SEND_CR_GAD);
  186.         NewGadget . ng_GadgetID        = Counter;
  187.  
  188.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  189.             SZ_Adjust,    TRUE,
  190.             SZ_AutoWidth,    TRUE,
  191.             SZ_NewColumn,    TRUE,
  192.  
  193.             GTCY_Labels,    CRType,
  194.             GTCY_Active,    ConfigPtr -> TerminalConfig -> SendCR,
  195.         TAG_DONE);
  196.  
  197.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_SEND_LF_GAD);
  198.         NewGadget . ng_GadgetID        = Counter;
  199.  
  200.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  201.             SZ_Adjust,    TRUE,
  202.             SZ_AutoWidth,    TRUE,
  203.  
  204.             GTCY_Labels,    LFType,
  205.             GTCY_Active,    ConfigPtr -> TerminalConfig -> SendLF,
  206.         TAG_DONE);
  207.  
  208.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_RECEIVE_CR_GAD);
  209.         NewGadget . ng_GadgetID        = Counter;
  210.  
  211.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  212.             SZ_Adjust,    TRUE,
  213.             SZ_AutoWidth,    TRUE,
  214.  
  215.             GTCY_Labels,    CRType,
  216.             GTCY_Active,    ConfigPtr -> TerminalConfig -> ReceiveCR,
  217.         TAG_DONE);
  218.  
  219.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_RECEIVE_LF_GAD);
  220.         NewGadget . ng_GadgetID        = Counter;
  221.  
  222.         GadgetArray[Counter++] = Gadget = CreateGadget(CYCLE_KIND,Gadget,&NewGadget,
  223.             SZ_Adjust,    TRUE,
  224.             SZ_AutoWidth,    TRUE,
  225.  
  226.             GTCY_Labels,    LFType,
  227.             GTCY_Active,    ConfigPtr -> TerminalConfig -> ReceiveLF,
  228.         TAG_DONE);
  229.  
  230.         if(ConfigPtr != Config)
  231.         {
  232.             LocalMaxColumns    = 132;
  233.             LocalMaxLines    = 64;
  234.         }
  235.         else
  236.         {
  237.             LocalMaxColumns    = WindowWidth  / TextFontWidth;
  238.             LocalMaxLines    = WindowHeight / TextFontHeight;
  239.         }
  240.  
  241.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_NUMCOLUMNS_GAD);
  242.         NewGadget . ng_GadgetID        = Counter;
  243.  
  244.         if(ConfigPtr -> TerminalConfig -> NumColumns < 20)
  245.             Level = LocalMaxColumns + 1;
  246.         else
  247.             Level = ConfigPtr -> TerminalConfig -> NumColumns;
  248.  
  249.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  250.             SZ_Adjust,        TRUE,
  251.             SZ_AutoWidth,        TRUE,
  252.  
  253.             GTSL_Min,        20,
  254.             GTSL_Max,        LocalMaxColumns + 1,
  255.             GTSL_Level,        Level,
  256.             GTSL_DispFunc,        ShowColumn,
  257.             GTSL_LevelFormat,    "%s",
  258.             GTSL_MaxLevelLen,    9,
  259.         TAG_DONE);
  260.  
  261.         if(ConfigPtr -> TerminalConfig -> NumLines < 20)
  262.             Level = LocalMaxLines + 1;
  263.         else
  264.             Level = ConfigPtr -> TerminalConfig -> NumLines;
  265.  
  266.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_NUMLINES_GAD);
  267.         NewGadget . ng_GadgetID        = Counter;
  268.  
  269.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  270.             SZ_Adjust,        TRUE,
  271.             SZ_AutoWidth,        TRUE,
  272.  
  273.             GTSL_Min,        20,
  274.             GTSL_Max,        LocalMaxLines + 1,
  275.             GTSL_Level,        Level,
  276.             GTSL_DispFunc,        ShowLine,
  277.             GTSL_LevelFormat,    "%s",
  278.             GTSL_MaxLevelLen,    9,
  279.         TAG_DONE);
  280.  
  281.         NewGadget . ng_GadgetText    = LocaleString(MSG_TERMINALPANEL_KEYMAP_FILE_GAD);
  282.         NewGadget . ng_GadgetID        = Counter;
  283.  
  284.         GadgetArray[Counter++] = Gadget = CreateGadget(STRING_KIND,Gadget,&NewGadget,
  285.             SZ_Adjust,    TRUE,
  286.             SZ_AutoWidth,    TRUE,
  287.             SZ_LeaveFolder,    TRUE,
  288.  
  289.             GTST_MaxChars,    255,
  290.             GTST_String,    ConfigPtr -> TerminalConfig -> KeyMapFileName,
  291.         TAG_DONE);
  292.  
  293.         NewGadget . ng_GadgetID        = Counter;
  294.  
  295.         GadgetArray[Counter++] = Gadget = CreateGadget(FILE_KIND,Gadget,&NewGadget,
  296.             SZ_Adjust,    TRUE,
  297.             SZ_AutoWidth,    TRUE,
  298.             SZ_PlaceLeft,    TRUE,
  299.         TAG_DONE);
  300.  
  301.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_USE_GAD),0,NULL);
  302.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_CANCEL_GAD),0,NULL);
  303.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_DEFAULT_GAD),0,NULL);
  304.  
  305.         SZ_SetWidth(SZ_ResetMaxWidth());
  306.  
  307.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_USE_GAD);
  308.         NewGadget . ng_GadgetID        = Counter;
  309.         NewGadget . ng_Flags        = 0;
  310.  
  311.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  312.             SZ_Adjust,    TRUE,
  313.             SZ_AutoWidth,    TRUE,
  314.             SZ_AlignExtra,    TRUE,
  315.             SZ_AlignLeft,    TRUE,
  316.             SZ_AlignBottom,    TRUE,
  317.         TAG_DONE);
  318.  
  319.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_CANCEL_GAD);
  320.         NewGadget . ng_GadgetID        = Counter;
  321.  
  322.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  323.             SZ_Adjust,    TRUE,
  324.             SZ_AutoWidth,    TRUE,
  325.             SZ_AlignRight,    TRUE,
  326.         TAG_DONE);
  327.  
  328.         if(Default)
  329.         {
  330.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_DEFAULT_GAD);
  331.             NewGadget . ng_GadgetID        = Counter;
  332.  
  333.             GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  334.                 SZ_Adjust,    TRUE,
  335.                 SZ_AutoWidth,    TRUE,
  336.                 SZ_AlignCentre,    TRUE,
  337.             TAG_DONE);
  338.         }
  339.     }
  340.  
  341.     return(Gadget);
  342. }
  343.  
  344.     /* SelectKeymap(UBYTE *Name,struct Window *ParentWindow):
  345.      *
  346.      *    Select a new keymap file using the asl.library file requester.
  347.      */
  348.  
  349. STATIC BYTE
  350. SelectKeymap(UBYTE *Name,struct Window *ParentWindow)
  351. {
  352.     struct FileRequester    *AslFileRequest;
  353.     UBYTE            *File,*Temp;
  354.     BYTE             NewMap = FALSE;
  355.  
  356.     File = Name;
  357.  
  358.     strcpy(SharedBuffer,File);
  359.  
  360.     Temp = PathPart(SharedBuffer);
  361.  
  362.     Temp[0] = 0;
  363.  
  364.     if(!SharedBuffer[0])
  365.     {
  366.         APTR OldPtr = ThisProcess -> pr_WindowPtr;
  367.         BPTR FileLock;
  368.  
  369.         ThisProcess -> pr_WindowPtr = (APTR)-1;
  370.  
  371.         if(FileLock = Lock("KEYMAPS:",ACCESS_READ))
  372.         {
  373.             strcpy(SharedBuffer,"KEYMAPS:");
  374.  
  375.             UnLock(FileLock);
  376.         }
  377.         else
  378.             strcpy(SharedBuffer,"Devs:Keymaps");
  379.  
  380.         ThisProcess -> pr_WindowPtr = OldPtr;
  381.     }
  382.  
  383.     File = FilePart(File);
  384.  
  385.     if(AslFileRequest = (struct FileRequester *)AllocAslRequestTags(ASL_FileRequest,
  386.         ASL_Window,    ParentWindow,
  387.         ASL_File,    File,
  388.         ASL_Dir,    SharedBuffer,
  389.         ASL_Hail,    LocaleString(MSG_TERMINALPANEL_SELECT_KEYMAP_TXT),
  390.         ASL_FuncFlags,    FILF_NEWIDCMP,
  391.         ASL_OKText,    LocaleString(MSG_GLOBAL_SELECT_TXT),
  392.     TAG_END))
  393.     {
  394.         if(AslRequestTags(AslFileRequest,TAG_DONE))
  395.         {
  396.             if(AslFileRequest -> rf_File[0])
  397.             {
  398.                 strcpy(SharedBuffer,AslFileRequest -> rf_Dir);
  399.  
  400.                 if(!AddPart(SharedBuffer,AslFileRequest -> rf_File,MAX_FILENAME_LENGTH))
  401.                     strcpy(SharedBuffer,AslFileRequest -> rf_File);
  402.  
  403.                 if(Stricmp(SharedBuffer,Name))
  404.                 {
  405.                     strcpy(Name,SharedBuffer);
  406.  
  407.                     NewMap = TRUE;
  408.                 }
  409.             }
  410.         }
  411.  
  412.         FreeAslRequest(AslFileRequest);
  413.     }
  414.  
  415.     return(NewMap);
  416. }
  417.  
  418. BYTE
  419. TerminalPanel(struct Configuration *Config,BYTE *Default)
  420. {
  421.     struct Window    *PanelWindow;
  422.     struct Gadget    *GadgetList = NULL;
  423.     struct Gadget    *GadgetArray[GAD_DEFAULT + 1];
  424.     UBYTE         DummyBuffer[MAX_FILENAME_LENGTH];
  425.     LONG         MinWidth,MinHeight,
  426.              MaxWidth,MaxHeight;
  427.  
  428.     Forbid();
  429.  
  430.     MinWidth    = Window -> MinWidth;
  431.     MinHeight    = Window -> MinHeight;
  432.     MaxWidth    = Window -> MaxWidth;
  433.     MaxHeight    = Window -> MaxHeight;
  434.  
  435.     WindowLimits(Window,Window -> Width,Window -> Height,Window -> Width,Window -> Height);
  436.  
  437.     Permit();
  438.  
  439.     SaveConfig(Config,PrivateConfig);
  440.  
  441.     if(CreateAllGadgets(Config,GadgetArray,&GadgetList,Default))
  442.     {
  443.         if(PanelWindow = OpenWindowTags(NULL,
  444.             WA_Left,    GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
  445.             WA_Top,        GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight())    / 2,
  446.             WA_Width,    SZ_GetWindowWidth(),
  447.             WA_Height,    SZ_GetWindowHeight(),
  448.  
  449.             WA_Activate,    TRUE,
  450.             WA_DragBar,    TRUE,
  451.             WA_DepthGadget,    TRUE,
  452.             WA_RMBTrap,    TRUE,
  453.             WA_DepthGadget,    TRUE,
  454.             WA_CloseGadget,    TRUE,
  455.             WA_CustomScreen,Window -> WScreen,
  456.  
  457.             WA_IDCMP,    IDCMP_ACTIVEWINDOW | IDCMP_CLOSEWINDOW | IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_GADGETDOWN | SLIDERIDCMP | BUTTONIDCMP | CHECKBOXIDCMP | CYCLEIDCMP | STRINGIDCMP,
  458.  
  459.             WA_Title,    LocaleString(MSG_TERMINALPANEL_TERMINAL_PREFERENCES_TXT),
  460.         TAG_DONE))
  461.         {
  462.             struct IntuiMessage    *Massage;
  463.             ULONG             IClass,Code;
  464.             struct Gadget        *Gadget;
  465.             BYTE             Terminated = FALSE;
  466.  
  467.             GuideContext(CONTEXT_TERMINAL);
  468.  
  469.             PushWindow(PanelWindow);
  470.  
  471.             AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  472.             RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  473.             GT_RefreshWindow(PanelWindow,NULL);
  474.  
  475.             GT_SetGadgetAttrs(GadgetArray[GAD_FONTMODE],PanelWindow,NULL,
  476.                 GA_Disabled,    Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  477.             TAG_DONE);
  478.  
  479.             GT_SetGadgetAttrs(GadgetArray[GAD_SELECT_FONT],PanelWindow,NULL,
  480.                 GA_Disabled,    Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  481.             TAG_DONE);
  482.  
  483.             ActiveGadget = NULL;
  484.  
  485.             ClrSignal(SIG_BREAK);
  486.  
  487.             while(!Terminated)
  488.             {
  489.                 if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  490.                 {
  491.                     SaveConfig(PrivateConfig,Config);
  492.  
  493.                     break;
  494.                 }
  495.  
  496.                 while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  497.                 {
  498.                     IClass    = Massage -> Class;
  499.                     Code    = Massage -> Code;
  500.                     Gadget    = (struct Gadget *)Massage -> IAddress;
  501.  
  502.                     GT_ReplyIMsg(Massage);
  503.  
  504.                     KeySelect(GadgetArray,GAD_CANCEL,Code,PanelWindow,&Gadget,&IClass,&Code);
  505.  
  506.                     if(IClass == IDCMP_GADGETDOWN)
  507.                     {
  508.                         if((Gadget -> GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET)
  509.                             ActiveGadget = Gadget;
  510.                     }
  511.  
  512.                     if(IClass == IDCMP_ACTIVEWINDOW && ActiveGadget)
  513.                         ActivateGadget(ActiveGadget,PanelWindow,NULL);
  514.  
  515.                     if(IClass == IDCMP_CLOSEWINDOW)
  516.                     {
  517.                         SaveConfig(PrivateConfig,Config);
  518.  
  519.                         Terminated = TRUE;
  520.                     }
  521.  
  522.                     if(IClass == IDCMP_MOUSEMOVE)
  523.                     {
  524.                         switch(Gadget -> GadgetID)
  525.                         {
  526.                             case GAD_NUMCOLUMNS:
  527.  
  528.                                 Config -> TerminalConfig -> NumColumns = Code % (LocalMaxColumns + 1);
  529.                                 break;
  530.  
  531.                             case GAD_NUMLINES:
  532.  
  533.                                 Config -> TerminalConfig -> NumLines = Code % (LocalMaxLines + 1);
  534.                                 break;
  535.                         }
  536.                     }
  537.  
  538.                     if(IClass == IDCMP_GADGETUP)
  539.                     {
  540.                         switch(Gadget -> GadgetID)
  541.                         {
  542.                             case GAD_BELLMODE:
  543.  
  544.                                 Config -> TerminalConfig -> BellMode = Code;
  545.                                 break;
  546.  
  547.                             case GAD_ALERTMODE:
  548.  
  549.                                 Config -> TerminalConfig -> AlertMode = Code;
  550.                                 break;
  551.  
  552.                             case GAD_EMULATIONMODE:
  553.  
  554.                                 Config -> TerminalConfig -> EmulationMode = Code;
  555. /*
  556.                                 GT_SetGadgetAttrs(GadgetArray[GAD_NUMCOLUMNS],PanelWindow,NULL,
  557.                                     GA_Disabled,    Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  558.                                 TAG_DONE);
  559.  
  560.                                 GT_SetGadgetAttrs(GadgetArray[GAD_NUMLINES],PanelWindow,NULL,
  561.                                     GA_Disabled,    Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  562.                                 TAG_DONE);
  563. */
  564.                                 GT_SetGadgetAttrs(GadgetArray[GAD_SELECT_FONT],PanelWindow,NULL,
  565.                                     GA_Disabled,    Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  566.                                 TAG_DONE);
  567.  
  568.                                 GT_SetGadgetAttrs(GadgetArray[GAD_FONTMODE],PanelWindow,NULL,
  569.                                     GA_Disabled,    Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL,
  570.                                 TAG_DONE);
  571.  
  572.                                 break;
  573.  
  574.                             case GAD_FONTMODE:
  575.  
  576.                                 Config -> TerminalConfig -> FontMode = Code;
  577.                                 break;
  578.  
  579.                             case GAD_SEND_CR:
  580.  
  581.                                 Config -> TerminalConfig -> SendCR = Code;
  582.                                 break;
  583.  
  584.                             case GAD_SEND_LF:
  585.  
  586.                                 Config -> TerminalConfig -> SendLF = Code;
  587.                                 break;
  588.  
  589.                             case GAD_RECEIVE_CR:
  590.  
  591.                                 Config -> TerminalConfig -> ReceiveCR = Code;
  592.                                 break;
  593.  
  594.                             case GAD_RECEIVE_LF:
  595.  
  596.                                 Config -> TerminalConfig -> ReceiveLF = Code;
  597.                                 break;
  598.  
  599.                             case GAD_NUMCOLUMNS:
  600.  
  601.                                 Config -> TerminalConfig -> NumColumns = Code % (LocalMaxColumns + 1);
  602.                                 break;
  603.  
  604.                             case GAD_NUMLINES:
  605.  
  606.                                 Config -> TerminalConfig -> NumLines = Code % (LocalMaxLines + 1);
  607.                                 break;
  608.  
  609.                             case GAD_SELECT_EMULATION:
  610.  
  611.                                 BlockWindow(PanelWindow);
  612.  
  613.                                 strcpy(DummyBuffer,SZ_GetString(GadgetArray[GAD_EMULATION]));
  614.                                 strcpy(SharedBuffer,DummyBuffer);
  615.  
  616.                                 if(PickFile("Libs:","xem#?.library",LocaleString(MSG_TERMINALPANEL_SELECT_EMULATOR_TXT),SharedBuffer))
  617.                                 {
  618.                                     if(Stricmp(SharedBuffer,DummyBuffer))
  619.                                     {
  620.                                         GT_SetGadgetAttrs(GadgetArray[GAD_EMULATION],PanelWindow,NULL,
  621.                                             GTST_String,SharedBuffer,
  622.                                         TAG_DONE);
  623.                                     }
  624.                                 }
  625.  
  626.                                 ReleaseWindow(PanelWindow);
  627.  
  628.                                 break;
  629.  
  630.                             case GAD_SELECT_KEYMAP:
  631.  
  632.                                 BlockWindow(PanelWindow);
  633.  
  634.                                 strcpy(DummyBuffer,SZ_GetString(GadgetArray[GAD_KEYMAP]));
  635.  
  636.                                 if(SelectKeymap(DummyBuffer,PanelWindow))
  637.                                 {
  638.                                     GT_SetGadgetAttrs(GadgetArray[GAD_KEYMAP],PanelWindow,NULL,
  639.                                         GTST_String,DummyBuffer,
  640.                                     TAG_DONE);
  641.                                 }
  642.  
  643.                                 ReleaseWindow(PanelWindow);
  644.  
  645.                                 break;
  646.  
  647.                             case GAD_SELECT_FONT:
  648.  
  649.                                 BlockWindow(PanelWindow);
  650.  
  651.                                 if(PickFont(PanelWindow,Config -> TerminalConfig -> TextFontName,&Config -> TerminalConfig -> TextFontHeight,TRUE))
  652.                                 {
  653.                                     SPrintf(SharedBuffer,"%s %ld",Config -> TerminalConfig -> TextFontName,Config -> TerminalConfig -> TextFontHeight);
  654.  
  655.                                     GT_SetGadgetAttrs(GadgetArray[GAD_FONT],PanelWindow,NULL,
  656.                                         GTTX_Text,    SharedBuffer,
  657.                                     TAG_DONE);
  658.                                 }
  659.  
  660.                                 ReleaseWindow(PanelWindow);
  661.  
  662.                                 break;
  663.  
  664.                             case GAD_USE:
  665.  
  666.                                 Terminated = TRUE;
  667.  
  668.                                 strcpy(Config -> TerminalConfig -> KeyMapFileName,    SZ_GetString(GadgetArray[GAD_KEYMAP]));
  669.                                 strcpy(Config -> TerminalConfig -> EmulationFileName,    SZ_GetString(GadgetArray[GAD_EMULATION]));
  670.  
  671.                                 if(!Config -> TerminalConfig -> EmulationFileName[0] && Config -> TerminalConfig -> EmulationMode == EMULATION_EXTERNAL)
  672.                                     Config -> TerminalConfig -> EmulationMode = EMULATION_ANSIVT100;
  673.  
  674.                                 break;
  675.  
  676.                             case GAD_CANCEL:
  677.  
  678.                                 Terminated = TRUE;
  679.  
  680.                                 SaveConfig(PrivateConfig,Config);
  681.  
  682.                                 break;
  683.  
  684.                             case GAD_DEFAULT:
  685.  
  686.                                 *Default    = TRUE;
  687.  
  688.                                 Terminated    = TRUE;
  689.  
  690.                                 break;
  691.                         }
  692.                     }
  693.                 }
  694.             }
  695.  
  696.             RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  697.  
  698.             PopWindow();
  699.  
  700.             CloseWindow(PanelWindow);
  701.         }
  702.     }
  703.  
  704.     FreeGadgets(GadgetList);
  705.  
  706.     WindowLimits(Window,MinWidth,MinHeight,MaxWidth,MaxHeight);
  707.  
  708.     return((BYTE)memcmp(PrivateConfig -> TerminalConfig,Config -> TerminalConfig,sizeof(struct TerminalSettings)));
  709. }
  710.